package com.app.jzgdirector.splash.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.app.jzgdirector.MainActivity;
import com.app.jzgdirector.R;
import com.app.jzgdirector.base.activity.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by lishihong on 2017/4/19.
 */

public class SplashActivity extends BaseActivity {
    @BindView(R.id.cut_count)
    TextView cutCountTv;
    @BindView(R.id.cut_text)
    TextView cutTextTv;
    private MyCountDownTimer mc;

    private boolean canClick = true;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getmToolbar().setVisibility(View.GONE);
        mc = new MyCountDownTimer(3000, 1000);
        mc.start();

        //调用接口的数据
//        StorageUtils.test();
//        String path = "http://gslb.miaopai.com/stream/oxX3t3Vm5XPHKUeTS-zbXA__.mp4";
//        Intent intent = new Intent(this,ApkDownloadService.class);
//        intent.putExtra("downUrl",path);
//        startService(intent);

    }

    @Override
    protected int layoutId() {
        return R.layout.activity_splash;
    }

    @OnClick(R.id.im_splash)
    public void splash() {
        if (canClick) {
            goNnet();
        }
    }

    private void goNnet() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    class MyCountDownTimer extends CountDownTimer {
        public MyCountDownTimer(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
        }

        public void onFinish() {
            cutTextTv.setText("正在跳转...");
            canClick = false;
            cutCountTv.setVisibility(View.GONE);
            goNnet();
        }

        public void onTick(long millisUntilFinished) {
            cutCountTv.setText(String.valueOf(millisUntilFinished / 1000));
        }
    }
}
